<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <title><%= htmlWebpackPlugin.options.title %></title>
    <script>
      // 在页面加载时立即抑制所有DOM警告
      (function () {
        // 保存原始方法
        const originalWarn = console.warn;
        const originalError = console.error;
        const originalLog = console.log;
        const originalInfo = console.info;
        const originalDebug = console.debug;

        // 检查是否应该抑制的消息
        function shouldSuppress(message) {
          if (!message || typeof message !== "string") return false;
          const lowerMessage = message.toLowerCase();
          return (
            lowerMessage.includes("domnodeinserted") ||
            lowerMessage.includes("domnoderemoved") ||
            lowerMessage.includes("domsubtreemodified") ||
            lowerMessage.includes("domattrmodified") ||
            lowerMessage.includes("mutation event") ||
            lowerMessage.includes("deprecation") ||
            lowerMessage.includes("quill") ||
            lowerMessage.includes("quill.js") ||
            lowerMessage.includes("domnodeinserted") ||
            lowerMessage.includes("domnoderemoved") ||
            lowerMessage.includes("domsubtreemodified")
          );
        }

        // 重写所有console方法
        console.warn = function (...args) {
          if (shouldSuppress(args[0])) return;
          originalWarn.apply(console, args);
        };

        console.error = function (...args) {
          if (shouldSuppress(args[0])) return;
          originalError.apply(console, args);
        };

        console.log = function (...args) {
          if (shouldSuppress(args[0])) return;
          originalLog.apply(console, args);
        };

        console.info = function (...args) {
          if (shouldSuppress(args[0])) return;
          originalInfo.apply(console, args);
        };

        console.debug = function (...args) {
          if (shouldSuppress(args[0])) return;
          originalDebug.apply(console, args);
        };

        // 重写addEventListener来阻止DOM事件监听
        const originalAddEventListener = EventTarget.prototype.addEventListener;
        EventTarget.prototype.addEventListener = function (
          type,
          listener,
          options
        ) {
          if (
            type === "DOMNodeInserted" ||
            type === "DOMNodeRemoved" ||
            type === "DOMSubtreeModified"
          ) {
            return; // 阻止这些已废弃的事件监听
          }
          return originalAddEventListener.call(this, type, listener, options);
        };

        // 重写removeEventListener
        const originalRemoveEventListener =
          EventTarget.prototype.removeEventListener;
        EventTarget.prototype.removeEventListener = function (
          type,
          listener,
          options
        ) {
          if (
            type === "DOMNodeInserted" ||
            type === "DOMNodeRemoved" ||
            type === "DOMSubtreeModified"
          ) {
            return; // 阻止这些已废弃的事件监听
          }
          return originalRemoveEventListener.call(
            this,
            type,
            listener,
            options
          );
        };

        console.log("DOM警告抑制已启用");
      })();
    </script>
  </head>
  <body>
    <noscript>
      <strong
        >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
        properly without JavaScript enabled. Please enable it to
        continue.</strong
      >
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>
